home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / createWake.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.0 KB  |  84 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  2002
  22. //  Author:         DRB
  23. //
  24. // Description: Create a pond, or fluid with a water surface simulation
  25. //                if it does not exist already, and then create wake and foam emitters for selected objects.
  26. //    
  27.  
  28. proc string createWakeEmitter(string $wakeFluid, float $wakeIntensity, float $foamIntensity)
  29. {
  30.     // Create a fluid emitter for the passed in wakeFluid and set the density and temperature
  31.     // emission rates
  32.     string $emitter[] = `fluidEmitter -n "PondWakeEmitter#" -pos 0 0 0 -type volume -vsh sphere -der $wakeIntensity -her $foamIntensity -fer 1 -fdr 2 -r 100.0 -cye none -cyi 1 -mxd 1 -mnd 0 `;
  33.     setAttr ($emitter[0] + ".fluidDropoff") 0.5;
  34.     setAttr ($emitter[0] + ".fluidJitter") 0;
  35.     connectDynamic -em $emitter[0] $wakeFluid;
  36.     if( $foamIntensity > 0.0 ){
  37.         setAttr ($wakeFluid + ".temperatureMethod") 2;
  38.     }
  39.  
  40.     string $emitNotes = ("The following emitter attributes control wake behavior:\n"
  41.                         +"Density/Voxel/Sec controls the wake intensity.\n"
  42.                         +"Heat/Voxel/Sec controls foam creation if the Temperature Method "
  43.                         +"on the pond is set to Dynamic Grid.");
  44.     addAttr -sn nts -ln notes -dt "string" $emitter[0];
  45.     setAttr -type "string" ($emitter[0] + ".notes") $emitNotes;
  46.  
  47.     return($emitter[0]);
  48. }
  49.  
  50. global proc createWake( float $wakeIntensity, float $foamIntensity)
  51. {
  52.     if( !fluidEditLicenseFound() ) {    
  53.         error( "Fluid license not found." );
  54.         return;
  55.     }
  56.     string $wakeFluid = getCurrentPond();
  57.     if( $wakeFluid == "" ){
  58.         return;
  59.     }
  60.     // get objects to create wakes for
  61.     string $sel[] = `ls -sl`; // restrict to transforms??
  62.     int $numSel = size($sel);
  63.     int $foundActualBoat = false;
  64.  
  65.     if( $numSel > 0 ){
  66.         for( $i = 0; $i < $numSel; $i++ ){
  67.             string $boatObj = $sel[$i];
  68.             if( isValidBoatObject( $boatObj ) ){
  69.                 string $emitter = createWakeEmitter($wakeFluid, $wakeIntensity, $foamIntensity);
  70.                 // parent the emitter under the boat
  71.                 parent -r $emitter $boatObj;
  72.                 $foundActualBoat = true;
  73.                 
  74.             }
  75.         }
  76.     }
  77.  
  78.     if(!$foundActualBoat) {
  79.         // create wake without an object if nothing is selected
  80.         createWakeEmitter($wakeFluid, $wakeIntensity, $foamIntensity);
  81.     }
  82.  
  83. }
  84.